package com.cq.service.Impl;

import com.cq.dao.EmployeeDao;
import com.cq.dao.UserDao;
import com.cq.pojo.Employee;
import com.cq.pojo.Student;
import com.cq.pojo.User;
import com.cq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private UserDao userDao;

    @Autowired
    public void setUserService(UserDao userDao) {
        this.userDao = userDao;
    }

/* 管理员对user表操作部分 */

    @Override
    public User queryUser(String userId) {
        User user = userDao.queryUser(userId);
        return user;
    }

    @Override
    public List<User> queryAllUser() {
        List<User> userList = userDao.queryAllUser();
        return userList;
    }

    @Override
    public int insertUser(User user) {
        return userDao.insertUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public int deleteUser(String UserId) {
        return userDao.deleteUser(UserId);
    }


/* 管理员对student表操作部分 */
    @Override
    public List<Student> queryAllStu() {
        List<Student> stu = userDao.queryAllStu();
        return stu;
    }

    @Override
    public int updateOneStu(Student student) {
        return userDao.updateStu(student);
    }

    @Override
    public int insertOneStu(Student student) {
        int result = userDao.insertStu(student);
        return result;
    }

    @Override
    public int deleteOneStu(int key) {
        int result = userDao.deleteStu(key);
        return result;
    }

    @Override
    public int updateStuLiveDorm(int stu_key, int dor_id) {
        int result = userDao.updateStuLiveDorm(stu_key,dor_id);
        return result;
    }

    @Override
    public int updateStuLiveBuild(int stu_key, int build_id) {
        int result = userDao.updateStuLiveBuild(stu_key,build_id);
        return result;
    }

    @Override
    public int updateStuLiveBuildName(int build_id, String build_name) {
        int result = userDao.updateStuLiveBuildName(build_id,build_name);
        return result;
    }

    @Override
    public int addDormFact(int dor_id) {
        int result = userDao.addDormFact(dor_id);
        return result;
    }

    @Override
    public int deleteOneDormFact(int dor_id) {
        int result = userDao.deleteOneDormFact(dor_id);
        return result;
    }


    /* 管理员对employee表操作部分 */
    @Override
    public List<Employee> queryAllEmp() {
        List<Employee> emp = userDao.queryAllEmp();
        return emp;
    }

    @Override
    public int updateOneEmp(Employee employee) {
        return userDao.updateEmp(employee);
    }

    @Override
    public int insertOneEmp(Employee employee) {
        return userDao.insertEmp(employee);
    }

    @Override
    public int deleteOneEmp(String Emp_Id) {
        return userDao.deleteEmp(Emp_Id);
    }

}
